Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix type narrowing for listener #84

Closed

Conversation

khromov
Copy link
Contributor

@khromov khromov commented Mar 26, 2024

Pull request checklist

Fixed type narrowing on event listeners

  • The changes have been tested successfully.

Copy link
Member

@robingenz robingenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please just use two addListener(…) methods. It’s easier to read.

@khromov
Copy link
Contributor Author

khromov commented Mar 26, 2024

After further testing the existing types work, I think perhaps the language server wasn't picking them up automatically without a restart which confused me. I tried in a brand new projects and this correctly type narrows the value of result:

npm i -D @capacitor-community/[email protected]
SpeechRecognition.addListener('partialResults', (result) => {
	console.log('Result:', result.matches);
});

SpeechRecognition.addListener('listeningState', (result) => {
	console.log('listeningState:', result.status);
});

@khromov khromov closed this Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants